#
# -= Makefile for module compile =-
#
# Usage:
# . Name this file as "Makefile";
#   Put it in the same directory as module's source code.
# . Change the ROOT definition, if necessary;
#   Make it point to the root of the software tree.
# . Define the Module Name in MOD as you like;
#   There should be NO duplicated module names in the whole project.
# . List all files want to be compiled in ASMS and/or SRCS;
#   Including files, such as header files, must NOT be listed here.
# . List all library files this module may depends on in LIBS.
# . Give a new name in SMOD, if want to include sub-directories;
#   Write the linkage information at the end of file.
#

# Destination of definition files
ROOT = ../../../..

# Module Name
MOD = LLD_NIM_COMBO

# List of source files
ASMS =
# for M3327 & M3327C
SRCS =
# List of library files
LIBS =

# List of sub-modules
# Note: Can NOT be the same name as sub-directories.
SMOD = LLD_NIM_COMBO_TUN_MXL603 LLD_NIM_COMBO_TUN_TDA182I5A

# Following lines are the common description for all projects.
# Do NOT modify anything, unless you know what you are doing.
include ${ROOT}/src/path.def
include ${ROOT}/src/compiler.def

OBJS = ${ASMS:.S=.o} ${SRCS:.c=.o}
SMOD_ = ${SMOD:=_}
SMOD__ = ${SMOD:=__}


all : ${MOD}.mk
	${MAKE} -f ${MOD}.mk ${OBJS} ${SMOD}
ifneq ($(strip $(OBJS)),)  # ${ASMS} ${SRCS} have source code file need to be compiled.
	cp -f ${OBJS} ${LIB_DIR}
endif
ifneq ($(strip $(LIBS)),)  # ${LIBS} is not empty.
	cp -f ${LIBS} ${LIB_DIR}
endif
	echo ${OBJS} ${LIBS} \\ > ${LIB_DIR}/${MOD}.lst
	echo ${MOD}.lst \\ >> ${LIB_DIR}/list.mod
	echo ${MOD}.lst \\ >> ${LIB_DIR}/list.sdk

${MOD}.mk : ${ASMS} ${SRCS}
	cp -f Makefile $@
	chmod +w $@
ifneq ($(strip $(OBJS)),)  # ${ASMS} ${SRCS} have source code file need to be compiled.
	${CC} ${CFLAGS} -M ${ASMS} ${SRCS} >> $@
endif

ddk_rel : ${SMOD__}
ifneq ($(strip $(OBJS)),)  # ${ASMS} ${SRCS} have source code file need to be compiled.
	${CC} ${CFLAGS} -M ${ASMS} ${SRCS} > dep.txt
else
  #	Just for copy makefile when no source code file.
  #	But file.txt generated by genlist will include a error copy command "cp ./ ...".
	echo "" > dep.txt
endif
	${DDK_DIR}/genlist dep.txt "${BASE_DIR}" "${BASE_DIR}/../ddk_release" "${BASE_DIR}/../ddk_release" "${BASE_DIR}/../ddk_release" 1>file.txt 2>dir.txt
	sh dir.txt
	sh file.txt
	rm -f dep.txt
	rm -f dir.txt
	rm -f file.txt

clean : ${SMOD_}
	rm -f ${OBJS} ${MOD}.mk
	cd ${LIB_DIR}; \
	  echo rm -f \\ > rm.sh; \
	  cat ${MOD}.lst >> rm.sh; \
	  sh < rm.sh; \
	  rm -f rm.sh ${MOD}.lst

rebuild: clean all
# End of common description.

# Construct of sub-modules
LLD_NIM_COMBO_TUN_MXL603 :
	cd tun_mxl603; \
	  ${MAKE}

LLD_NIM_COMBO_TUN_MXL603_ :
	cd tun_mxl603; \
	  ${MAKE} clean

LLD_NIM_COMBO_TUN_MXL603__ :
	cd tun_mxl603; \
	  ${MAKE} ddk_rel

LLD_NIM_COMBO_TUN_TDA182I5A :
	cd tun_tda182i5a; \
	  ${MAKE}

LLD_NIM_COMBO_TUN_TDA182I5A_ :
	cd tun_tda182i5a; \
	  ${MAKE} clean

LLD_NIM_COMBO_TUN_TDA182I5A__ :
	cd tun_tda182i5a; \
	  ${MAKE} ddk_rel

# Deconstruct of sub-modules
